const { defineConfig } = require("@vue/cli-service");
const path = require('path');

module.exports = defineConfig({
  transpileDependencies: true,

  outputDir: '../hub', // 构建文件保存在 Spring Boot 的静态资源目录中  
  assetsDir: 'hub', // 静态资源将存储在 static 文件夹  
  publicPath: '/',
  indexPath: 'hub.html', // 修改生成的 HTML 文件名为 hub.html

  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    }
  },

  devServer: {
    port: 3000,
    proxy: {
      '/government': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        ws: true,
        secure: false,
        onProxyReq: (proxyReq, req, res) => {
          // 添加必要的请求头
          // proxyReq.setHeader('Accept', 'text/event-stream');
          proxyReq.setHeader('Cache-Control', 'no-cache');
          proxyReq.setHeader('Connection', 'keep-alive');
        },
        pathRewrite: {
          '^/government': '/api/government'
        }
      }
    }
  }
});